package univ.paris.ouest.service.user;

import java.util.List;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.springframework.beans.factory.annotation.Autowired;

import univ.paris.ouest.data.IUserLoginDao;
import univ.paris.ouest.data.user.IUserDao;
import univ.paris.ouest.domaine.user.User;

public class UserManager implements IUser{
	@Autowired
	private IUserLoginDao userLoginDaoHib;
	@Autowired
	private IUserDao userDaoHib;
	@Autowired
	private SessionFactory sessionFactory;
	private Transaction tx;
	private Session session;

	@Override
	public User getUser(String nom, String prenom) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public User getUser(User user) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<User> getAllUsers() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void creatUser(User user) {
		this.session=this.sessionFactory.openSession();
	    this.tx=this.session.beginTransaction();
	    this.userDaoHib.setSession(this.session);this.userLoginDaoHib.setSession(this.session);
	    this.userLoginDaoHib.saveUserLogin(user.getUserLogin());
		this.userDaoHib.saveUser(user);
		this.tx.commit();this.session.close();
	}

	@Override
	public void upDateUser(User user) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void deleteUser(User user) {
		// TODO Auto-generated method stub
		
	}

}
